﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Common.DTO;
using LogicLayer;

namespace ImmoralServices
{
    /// <summary>
    /// Facade for calls regarding the player
    /// </summary>
    public class PlayerService : IPlayerService
    {
        // --- INFO ---

        /// <summary>
        /// Ajaxanrop vid skapande av spelare för att säkerställa att användarnamnet är unikt
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool CheckIfUsernameExists(string username)
        {
            return PlayerHandler.CheckIfPlayerWithUsernameExists(username);
        }

        // TODO_OL: Smartare lista. Inte alla
        public List<Player> GetAllPlayer()
        {
            return PlayerHandler.GetPlayerList();
        }

        // --- ACTIONS ---

        public bool CreatePlayer(string username, string password, string email)
        {
            return PlayerHandler.CreatePlayer(username, password, email);
        }

        /// <summary>
        /// Tries to use the credentials provided to find a Player in the Database
        /// with the provided username and password
        /// </summary>
        /// <param name="username">The name/username of the Player</param>
        /// <param name="password">The password of the Player</param>
        /// <returns>A Player-object if a Player is found. Otherwise NULL</returns>
        public Player LoginPlayer(string username, string password)
        {
            return PlayerHandler.LoginPlayer(username, password);
        }

    }
}
